/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package queenb.web.controller;

import java.util.ArrayList;
import java.util.List;
import queenb.net.entitybean.N100;
import queenb.web.sms.controller.M300Controller;
import queenb.web.util.SessionProvider;
import queenb.web.util.Util;

/**
 *
 * @author Hung.Ngo
 */
public class SMSController extends QueenbController {

    private List<N100> listSMS;
    private boolean selected = true;
    private String pageString;
    private String actionpage;
    private int idpage;
    private List<N100> listKH;

    public SMSController() {

        Object objAction = getRequest().getParameter("action");
        if (objAction != null) {
            if (objAction.equals("customer4tour")) {

                Object objpage = getRequest().getParameter("pageString");
                if (objpage != null) {
                    pageString = objpage.toString();
                }
                Object objpage1 = getRequest().getParameter("action");
                if (objpage1 != null) {
                    actionpage = objpage1.toString();
                }
            } else if (objAction.equals("customerSMSforUserLogin")) {
                if (SessionProvider.getSessionMapValue("listSelectedEx") != null) {
                    SessionProvider.removeSessionMapValue("listSelectedEx");
                }
                if (SessionProvider.getSessionMapValue("listSelected") != null) {
                    SessionProvider.removeSessionMapValue("listSelected");
                }
                //  objAction = actionpage;
                Object objpage = getRequest().getParameter("pageString");
                if (objpage != null) {
                    pageString = objpage.toString();
                }
                Object objpage1 = getRequest().getParameter("action");
                if (objpage1 != null) {
                    actionpage = objpage1.toString();
                }
                M300Controller m300Controller = new M300Controller();
                Object listselect = m300Controller.getListAllCustomerforUserlogin();
                if (listselect != null) {
                    try {
                        listKH = (List<N100>) listselect;
                    } catch (Exception e) {
                        listKH = new ArrayList<N100>();
                    }
                } else {
                    listKH = new ArrayList<N100>();
                }
                if (listselect != null) {
                    SessionProvider.setSessionMapValue("listSelected", listselect);
                    System.out.println("----day la lít ca nhan ---- view ----" + listKH.size());
                }
            } else if (objAction.equals("customerexpand")) {

                Object objpage = getRequest().getParameter("pageString");
                if (objpage != null) {
                    pageString = objpage.toString();
                }
                Object objpage1 = getRequest().getParameter("action");
                if (objpage1 != null) {
                    actionpage = objpage1.toString();
                }
            } else if (objAction.equals("employeeUser")) {
                if (SessionProvider.getSessionMapValue("listSelectedEx") != null) {
                    SessionProvider.removeSessionMapValue("listSelectedEx");
                }
                if (SessionProvider.getSessionMapValue("listSelected") != null) {
                    SessionProvider.removeSessionMapValue("listSelected");
                }
                //  objAction = actionpage;
                Object objpage = getRequest().getParameter("pageString");
                if (objpage != null) {
                    pageString = objpage.toString();
                }
                Object objpage1 = getRequest().getParameter("action");
                if (objpage1 != null) {
                    actionpage = objpage1.toString();
                }
                M300Controller m300Controller = new M300Controller();
                Object listselect = m300Controller.getListAllEmployeeSendSMS_Email();
                if (listselect != null) {
                    try {
                        listKH = (List<N100>) listselect;
                    } catch (Exception e) {
                        listKH = new ArrayList<N100>();
                    }
                } else {
                    listKH = new ArrayList<N100>();
                }
                if (listselect != null) {
                    SessionProvider.setSessionMapValue("listSelected", listselect);
                    System.out.println("----day la list nhân viên---- view ----" + listKH.size());
                }
            }
        }
    }

    /**
     * @return the listSMS
     */
    public List<N100> getListSMS() {
        listSMS = new ArrayList<N100>();
        Object listselect = null;
        if (SessionProvider.getSessionMapValue("listSelected") != null) {
            listselect = SessionProvider.getSessionMapValue("listSelected");

        } else if (SessionProvider.getSessionMapValue("listSelectedEx") != null) {
            listselect = SessionProvider.getSessionMapValue("listSelectedEx");
            System.out.println("------------DANH SACH DOARBAORD----------------" + listselect);
        }
        else if (SessionProvider.getSessionMapValue("listPersonalDSVN") != null) {
            listselect = SessionProvider.getSessionMapValue("listPersonalDSVN");
            System.out.println("------------DANH SACH NHAN VIEN  CONG TY----------------" + listselect);
        }else if (SessionProvider.getSessionMapValue("listPersonalDSDD") != null) {
            listselect = SessionProvider.getSessionMapValue("listPersonalDSDD");
            System.out.println("------------DANH SACH NHAN VIEN CONG TY- DAI DIEN---------------" + listselect);
        }
        if (listselect != null) {
            try {
                listSMS = (List<N100>) listselect;
                if (listSMS.size() > 0) {
                    selected = true;
                }
            } catch (Exception e) {
                listSMS = new ArrayList<N100>();
            }
        } else {
            listSMS = new ArrayList<N100>();
        }
        return listSMS;
    }

    /**
     * @param listSMS the listSMS to set
     */
    public void setListSMS(List<N100> listSMS) {
        this.listSMS = listSMS;
    }

    /**
     * @return the selected
     */
    public boolean isSelected() {
        return selected;
    }

    /**
     * @param selected the selected to set
     */
    public void setSelected(boolean selected) {
        this.selected = selected;
    }

    /**
     * @return the pageString
     */
    public String getPageString() {
        return pageString;
    }

    /**
     * @param pageString the pageString to set
     */
    public void setPageString(String pageString) {
        this.pageString = pageString;
    }

    /**
     * @return the actionpage
     */
    public String getActionpage() {
        return actionpage;
    }

    /**
     * @param actionpage the actionpage to set
     */
    public void setActionpage(String actionpage) {
        this.actionpage = actionpage;
    }

    /**
     * @return the idpage
     */
    public int getIdpage() {
        System.out.println("---------vo vao day ko????");
        if (SessionProvider.getSessionMapValue("NUMBERPER") != null) {
            idpage = Util.parseInt(SessionProvider.getSessionMapValue("NUMBERPER"));
        }
        return idpage;
    }

    /**
     * @param idpage the idpage to set
     */
    public void setIdpage(int idpage) {
        this.idpage = idpage;
    }
}
